var router = require('libs/router').router;
var pages = require('libs/pages');
var ItemMixin = require('mixins/item');
var libs = require('libs/libs');
var api = libs.api;
var List = require('modules/list/load_list')(true, 'wsStatus');
var expLogLogin = SA.get('USER');

var expStatusInt = {
    "orderLogs": [
        {
            createBy: "",
            createTime: "",
            description: "",
            logId: "",
            operations: "",
            operationsName: "",
            orderId: "",
            phone: "",
            remark: ""
        }
    ]
}


var bindEvent = function(){
    //此处各种dom 操作
    $('.send-status-list').find('li:first p.title').css({fontSize:'0.16rem',color:'#fa8733'})

};

var ExpLog = React.createClass({
    mixins: [ItemMixin],
    render:function(){
        var _data = this.props.data || [];
        var _block = _data.map(function(item,index){
            return (
                <li key={index} className={index==0?"active":""}>
                    <div className="box">
                        <p className="title">{item.description}</p>
                        <p className="time">{item.createTime}</p>
                    </div>
                </li>
            );
        });
        return(
            <div className="send-status flex flex-v">
                <div className="flex-1 f-oTouch">
                    <ul className="send-status-list">
                        {_block}
                    </ul>
                </div>
            </div>
        )
    }
});

function start(name){
    return pages.new({
        boot: function(){
        },
        trigger:function(self, data){
            this.libs.changeTitle('日志跟踪');    //更改当前页面标题
            if(data  && data.orderId){
                var param = {orderId: data.orderId,login: expLogLogin.login,method: 'get'};
                api.req('/exp_log', param, function(data){
                    // console.log(data);
                    self.main(self, data)
                })
            }
        },
        main: function(self, data){
            if(data){
                expStatusInt = data
            }
            this.render(
                <ExpLog itemDefaultMethod={bindEvent} data={expStatusInt} />,
                document.getElementById(name)
            )
        },
        end: function(){
            React.unmountComponentAtNode(document.getElementById(name))
        }
    })
}

module.exports = start;
